package co.yixiang.weixin.common.weixin.feign;


import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import co.yixiang.common.core.constant.ServiceNameConstants;
import co.yixiang.weixin.common.dto.WxPayDto;
import co.yixiang.weixin.common.weixin.hystrix.RemoteWexinFallbackFactory;
import co.yixiang.weixin.common.weixin.vo.LoginParam;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 微信服务
 *
 * @author yshop
 */
@FeignClient(contextId = "remoteWeinxinService", value = ServiceNameConstants.WEIXIN_SERVICE ,fallbackFactory = RemoteWexinFallbackFactory.class)
public interface RemoteWeixinService {

     /**
      * 微信支付远程调用接口
      * @param wxPayDto
      * @return
      */
     @PostMapping("/weixinPay/goPay")
     Map<String, Object> goPay(@RequestBody WxPayDto wxPayDto);


     /**
      * 刷新所有微信配置
      */
     @GetMapping("/weixinConfig/refreshAllWxConfig")
     void refreshAllWxConfig();

     /**
      * 刷新微信支付配置
      */
     @GetMapping("/weixinConfig/refreshWxPayConfig")
     void refreshWxPayConfig();


     /**
      * 小程序登录
      * @param loginParam
      * @return
      */
     @PostMapping("/weixinOauth/wxMaOauth")
     WxMaUserInfo wxMaOauth(@RequestBody LoginParam loginParam);

     /**
      * 微信公众号授权登录
      * @param code
      * @return
      */
     @GetMapping("/weixinOauth/wxMaOauth")
     WxMpUser wxMpOauth(@RequestParam("code") String code);

     /**
      * 统一支付远程调用接口
      * @param orderId
      * @param from
      * @param attach
      * @param body
      * @return
      */
     @PostMapping("/weixinPay/unifyPay")
     Object unifyPay(@RequestParam("orderId") String orderId, @RequestParam("from") String from,
                            @RequestParam("attach") String attach, @RequestParam("body") String body);
}
